
///客户信息显示
var queryCustomerData = {};
	queryCustomerData.key = "";
	var queryCustomerTable;
	jQuery(document).ready(function() {
		if(!window.canReadCustomer) return;
		queryCustomerTable = jQuery('#query-customer-table').DataTable({
			"serverSide" : true,
			"ordering" : false,
			"ajax" : {
				"dataType" : "json",
				"type" : "get",
				"cache" : false,
				"url" : window.rootPath
						+ '/ui/customer/getpage',
				"data" : function(d) {
					return $.extend({}, d,
							queryCustomerData);
				}
			},
			"iDisplayLength" : 5,
			columns : [
					{
						data : null
					},
					{
						data : null,
						defaultContent : "",
						render : function(data,type, full, meta) {
							var operate = '<input type="checkbox" class="checkCustomer">';
							return operate;
						}
					},	
					{
						data : 'customerCode'
					},
					{
						data : 'customerName'
					},
					{
						data : 'saleArea.superiorArea'
					},
					{
						data : 'business'
					},
					{
						data : 'superior'
					},
					{
						data : 'address'
					},
					{
						data : 'buyer'
					},
					{
						data : 'creditLevel'
					},
					{
						data : 'identification'
					},
					{
						data : 'invoicePhone'
					},
					{
						data : 'zipCode'
					},
					{
						data : 'invoiceAddress'
					},
					{
						data : 'invoiceBank'
					},
					{
						data : 'bankAccount'
					},
					
					{
						data : 'postUnit'
					},
					{
						data : 'postDelegate'
					},
					{
						data : 'postPhone'
					},
					{
						data : 'postZip'
					},
					{
						data : 'postAddress'
					},
					{
						data : 'taxNumber'
					},
					{
						data : 'cDHDB'
					},
					{
						data : 'cDHPhone'
					}
			],
			"drawCallback" : function(oSettings) {
				var k = 0;
				var total = oSettings.aiDisplay.length
						+ oSettings._iDisplayStart;
				for (var i = oSettings._iDisplayStart, iLen = total; i < iLen; i++) {
					$(
							'td:eq(0)',
							oSettings.aoData[oSettings.aiDisplay[k]].nTr)
							.text(i + 1);
					k++;
				}
			}
	});
		
});


function showCustomer(){
	jQuery('#query-customer-keyword').val('');
	queryCustomerData.key = "";
	queryCustomerTable.draw();
	jQuery("#query-Customer-Modal").modal('show');
	//搜索
	jQuery('#query-customer-search-btn').on('click', function() {
		queryCustomerData.key = jQuery('#query-customer-keyword').val();
		queryCustomerTable.draw();
	})
	// 撤销查询
	jQuery('#query-customer-reset-btn').on("click", function() {
		jQuery('#query-customer-keyword').val('');
		queryCustomerData.key = '';
		queryCustomerTable.draw();
	});	
}

/**
 * 前台插入一条待处理的任务,userId,taskId,type(0:处理人为个体，1 处理人为角色)
 */
function addTask(name,content,userId,type,taskId){
	var url = window.rootPath + "/ui/index/addUndoTask";
	var d = {
			"userId":userId,
			"name" : name,
			"content" : content,
			"taskId":taskId,
			"type":type
	}
	jQuery.ajax({
		type : 'get',
		url : encodeURI(url),
		data : d,
		dataType : 'json',
		success : function(d) {
			
		}
	});
	
}
/**
 * 前台删除待办任务
 */
function delTask(taskId,taskName){
	var url = window.rootPath + "/ui/index/delTask?taskId="+taskId+"&taskName="+taskName;
	jQuery.ajax({
		cache:false,
		type : 'get',
		url : encodeURI(url),
		dataType : 'json',
		success : function(d) {
			
		}
	});
	
}
	






